// 改文件是把Vue 路由相关代码进行抽离，方便后期维护

// 1.导入 Vue 路由模块
import Vue from 'vue'

// 2. 在Vue 中全局注册路由模块
import VueRouter from 'vue-router'
Vue.use(VueRouter)
// 3. 配置 路径与组件的映射规则
import Layout from '../views/Layout/index.vue'
import Home from '../views/Home/index.vue'
import Search from '../views/Search/index.vue'
import Play from '../views/Play/index.vue'
const routes = [
    { path: '/', redirect: '/layout' },
    { 
    path: '/layout', 
    component: Layout,
    redirect: '/layout/home',
    children:[
        { path:'home', component: Home , meta: { title:'首页' }},
        { path: 'search', component: Search, meta: { title: '搜索' } },
    ]
    },
    { path: '/play', component: Play },
]
// 4. new 一个路由实例  需要配置映射规则
const router = new VueRouter({
      routes,
    //   // 默认是hash 打包上下后需要后台支持，vuerouter官网有后台配置的参考代码
      mode:'history',
})
// 5. 导出 因为需要在main.js使用
export default router

